package com.yf.utils;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * User: Administrator
 * Date: 2018-12-12
 * Time: 14:57
 * Description:
 */
public class DateUtils extends DateUtil {
    //获取某个日期的后day日期
    public static Date nextDay(Date date, int day) {
        Calendar cal = Calendar.getInstance();
        if (date != null) {
            cal.setTime(date);
        }
        cal.add(Calendar.DAY_OF_YEAR, day);
        return cal.getTime();
    }

    public static boolean isToday(Date time) {
        boolean b = false;
        Date today = new Date();
        DateFormat dateFormat = getDateFormat();
        if (time != null) {
            String nowDate = dateFormat.format(today);
            String timeDate = dateFormat.format(time);
            if (nowDate.equals(timeDate)) {
                b = true;
            }
        }

        return b;
    }

    public static DateFormat getDateFormat() {
        return getDateFormat("yyyy-MM-dd");
    }
}
